<template>
  <div class='main-container'>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/staffGeneral' }">我的合同</el-breadcrumb-item>
      <el-breadcrumb-item>合同筛选</el-breadcrumb-item>
    </el-breadcrumb>
    <h4>
      我的 '{{getStatus(this.$route.params.status).text}}' 合同
    </h4>
    <!-- 卡片 -->
    <el-card class="box-card">
      <!-- 表格 -->
      <el-table :data="contractsList" style="width: 100%" border stripe>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="contractName" label="合同名称" ></el-table-column>
        <el-table-column prop="launchUser" label="发起人" width='70'></el-table-column>
        <el-table-column prop="receiveUser" label="签署人" width='70'></el-table-column>
        <el-table-column prop="launchTime" label="签署发起时间">
          <template slot-scope='scope'>
            {{scope.row.launchTime|dateFormat}}
          </template>
        </el-table-column>
        <el-table-column prop="ddl" label="签署截止时间" >
          <template slot-scope='scope'>
            {{scope.row.ddl|dateFormat}}
          </template>
        </el-table-column>
        <el-table-column prop="status" label="状态" >
          <template slot-scope="scope">
            <el-tag
              :type="getStatus(scope.row.status).color"
              disable-transitions>{{getStatus(scope.row.status).text}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column  label="操作" width="130">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="addToCar(scope.row)" class="el-icon-document-add"></el-button>
            <el-button type="danger" size="mini" @click="removeById(scope.row)" class="el-icon-delete"></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <!--    <el-pagination-->
      <!--        @size-change="handleSizeChange"-->
      <!--        @current-change="handleCurrentChange"-->
      <!--        :current-page="queryInfo.pagenum"-->
      <!--        :page-sizes="[1, 2, 5, 10]"-->
      <!--        :page-size="queryInfo.pageSize"-->
      <!--        layout="total, sizes, prev, pager, next, jumper"-->
      <!--        :total="total">-->
      <!--      </el-pagination>-->
    </el-card>
  </div>
</template>

<script>
  import login from '../Login'

  export default {
    name: 'StaffFilter',
    data(){
      return{
        contractsList:[],
      }
    },
    async created() {
      await this.getContactsList().then(()=>{
        this.contractsList=this.contractsList.filter(item=> item.status===parseInt(this.$route.params.status))
      })
    },
    methods:{
      getContactsList:async function(){
        // const {data:res}=await this.$http.get('shop/findAllcomm',)
        //   if(res.data.status!==200){
        //   return this.$message.error("获取失败")
        // }
        this.$message.success("获取合同列表成功")
        // this.contractsList=res.meta
        this.contractsList=JSON.parse(window.sessionStorage.getItem("contractsList"))
      },
      getStatus(val){
        let statusMap = {
          '0':{color:'warning',text:'待签署'},
          '1':{color:'success',text:'已签署'},
          '2':{color:'danger',text:'已过期'}
        }
        return statusMap[val]
      },
  }
  }
</script>

<style lang="less" scoped>
  .main-container{
    padding: 10px 20px !important;
    h4{
      color: gray;
      font-size:20px;
      font-weight: normal
    }
  }
</style>
